package com.lee.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

/**
 * @author liyacai
 * @description
 * @data 2020-05-08
 */
@RestController
@RequestMapping("/consumer")
public class ConsumerController {

    // private final String REST_URL_PREFIX = "http://www.lee.com:8001";
    // 名称是提供者的服务注册名称spring.application.name=Eureka-Provider
    private final String REST_URL_PREFIX = "http://Eureka-Provider";

    @Autowired
    private RestTemplate restTemplate;

    @GetMapping("/list")
    public String list() {
        ResponseEntity<String> content = restTemplate.getForEntity(REST_URL_PREFIX + "/provider/list", String.class);
        return String.format("消费者获取提供者数据[%s]", content);
    }

}
